<template>
  <!-- 填写邀请码 -->
  <div class="inviteCode">
    <div class="title">
      <img class="back" src="@/assets/img/icons/black/back.svg" @click="$router.back()" />
      <div class="t">
        <span class="a">填写邀请码立得</span>
        <span class="b">300金币</span>
      </div>
    </div>
    <k-scroll
      class="scroll"
      topColor="#F2693F"
      bottomColor="var(--main-background-color)"
      topType="stretch"
      bottomType="stretch"
    >
      <div class="content">
        <div class="box">
          <input v-model="code" type="text" maxlength="6" placeholder="输入好友的邀请码,可得300金币" />
        </div>
        <k-button class="btn" bgColor="#FA6724" fontSize="0.16rem" fontColor="#FEFEFE" @click="submit">提交</k-button>
        <div class="tip">温馨提示</div>
        <div class="a">1.新用户下载本APP后的十天内可以填写邀请码，绑定成功后将获得新用户奖励；</div>
        <div class="b">2.未曾绑定过好友的老用户填写邀请码，绑定成功后仅可获得一定金币补偿奖励；</div>
        <div class="c">3.一个手机只能输入一次邀请码；已输入邀请码的手机，切换账号也无法输入其他邀请码；</div>
        <div class="d">4.使用APP分身软件、高危手机号等非正常用户不能输入邀请码，且会被系统记录。</div>
      </div>
    </k-scroll>
  </div>
</template>

<script>
export default {
  name: 'inviteCode',
  data() {
    return {
      //邀请码
      code: '',
    }
  },
  methods: {
    //提交邀请码
    submit() {
      if (this.code == this.$store.state.userInfo.invitecode) {
        this.$dialog({
          title: '提交失败',
          message: '少侠，这是您自己的邀请码！',
        })
        return
      }
      this.$network
        .main('bindInviteCode', this.code)
        .then((data) => {
          this.$dialog({
            message: '绑定成功！恭喜获得300金币与3次抽奖机会！',
          })
          this.$updateUserInfo() //更新用户信息
        })
        .catch((err) => {
          this.$dialog({
            title: '提交失败',
            message: err,
          })
        })
    },
  },
}
</script>

<style scoped src="./index.less" lang="less"></style>
